package com.example.coursemanagement.controller;


import com.example.coursemanagement.MyUtils.CommonResult;
import com.example.coursemanagement.MyUtils.ResultCode;
import com.example.coursemanagement.mapper.CatalogueMapper;
import com.example.coursemanagement.pojo.Campus;
import com.example.coursemanagement.pojo.Catalogue;
import com.example.coursemanagement.service.ICampusService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yangmenghen
 * @since 2020-06-01
 */
@RestController
@RequestMapping("/campus" )
@RequiredArgsConstructor
public class CampusController {

    @Autowired
    private ICampusService campusService;

    @ApiOperation("发布校园资讯")
    @PostMapping("/publishCampus")
    public CommonResult<Object> publishCampus(@RequestBody Campus campus){
        return campusService.publishCampus(campus);
    }

    @ApiOperation("查询所有校园资讯")
    @GetMapping("/selectAllCampus")
    public CommonResult<Object> selectAllCampus(){
        return campusService.selectAllCampus();
    }

    @ApiOperation("修改资讯内容")
    @PutMapping("/updateCampus")
    public CommonResult<Object> updateCampus(@RequestBody Campus campus){
        return campusService.updateCampus(campus);
    }

    @ApiOperation("查询单个校园资讯")
    @GetMapping("/selectByCampusId")
    public CommonResult<Object> selectByCampusId(@RequestParam("campusId")Integer campusId){
        return campusService.selectByCampusId(campusId);
    }


    @ApiOperation("根据用户id查询校园资讯")
    @GetMapping("/selectByUserId")
    public CommonResult<Object> selectByUserId(@RequestParam("userId")Integer userId){
        return campusService.selectByUserId(userId);
    }

    @ApiOperation("删除校园资讯")
    @DeleteMapping("/deleteByCampusId")
    public CommonResult<Object> deleteByCampusId(@RequestParam("campusId")Integer campusId){
        return campusService.deleteByCampusId(campusId);
    }

}

